<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="org.apache.commons.beanutils.PropertyUtils" %>
<%@ page import="com.broadvision.web.servlet.SessionVisitor" %>

<%@ taglib uri="/WEB-INF/bpmapp.tld" prefix="ssp" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<% String ctPath = request.getContextPath(); %>

<%	
  SessionVisitor sessionVisitor = SessionVisitor.getInstance(session);
  int serviceId                 = sessionVisitor.getServiceId();
%>

<script language="javascript">
  
function doCategorySelect(ssp_process_oid, container, reqParam, exitURL, wantCtx) {
  
  var thisForm = document.form1;
  
  thisForm.ssp_process_oid.value = ssp_process_oid; 
  thisForm.container.value = container; 
  thisForm.reqParam.value = reqParam; 
  thisForm.exitURL.value = exitURL; 
  thisForm.wantCtx.value = wantCtx; 
      
  // 60 is the content type id for BV_CNT_SVCS
  doPickerPopupAction('<c:url value="/mt/categoryPickerPopup.do"/>', 'createContent', 60, null, null, null, null, null, null, null, 'com.broadvision.content.acl.common.CreateContentCategoryPickerFilter', null, false);
}

function createContent(ids, names) {
  var thisForm = document.form1;
  
  thisForm.action = '<html:rewrite page="/startWebflow.do"/>';
  thisForm.BV_II_CategoryOID.value = ids[0]; 
  thisForm.BV_II_ServiceId.value = <%=serviceId%>; 
  thisForm.BV_II_vsContentTypeId.value = 60; 
 
  thisForm.submit();
  return false;
}

</script>

<%@include file="/mt/common/pickerPopupHelper.jsp" %>

<jsp:useBean id="bv_user_logged_in" scope="session" class="java.lang.String" />

<logic:equal name="bv_user_logged_in" value="true">

<jsp:useBean id="docTypeView" scope="request" type="com.broadvision.web.util.ViewDynaBean"/> 

<form name="form1" action="">
<input type="hidden" name="ssp_process_oid">
<input type="hidden" name="container">
<input type="hidden" name="reqParam">
<input type="hidden" name="exitURL">
<input type="hidden" name="wantCtx">
<input type="hidden" name="BV_II_CategoryOID">
<input type="hidden" name="BV_II_ServiceId">
<input type="hidden" name="BV_II_vsContentTypeId">

<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<bean:message bundle="appCommonRes" key="bp.contentCreate.title"/>">
  <tr> 
  <td valign="top" width="100%">
		  
  <div class="pageTitle"><bean:message bundle="appCommonRes" key="bp.contentCreate.title"/></div>
  
  <div class="pageSubtitle">
    <span class="left"><bean:message bundle="appCommonRes" key="bp.contentCreate.title" /></span>
    <span class="right">&nbsp;</span>
  </div>
  
	<div class="blockWrap">  
  <table class="dataTable" border="0" cellspacing="1" cellpadding="2" width="100%" summary="<bean:message bundle="appCommonRes" key="bp.docVersions.versions.title" />">
  <tr class="listHeader"> 
    <th id="Name" align="left"><bean:message bundle="appCommonRes" key="bp.contentCreate.name" /></th>
    <th id="Friendly Name" align="left"><bean:message bundle="appCommonRes" key="bp.contentCreate.fname" /></th>
  </tr>     

  <logic:iterate id="result" name="docTypeView" property="docTypeList" indexId="index">  
    <tr class='<%=index.intValue() %2 == 0 ? "listEven" : "listOdd"%>'>
      <td headers="Content Name">
        <%
           Map params = (Map)PropertyUtils.getProperty(result, "urlParams");
           String ssp_process_oid = (String)params.get("ssp_process_oid");
           String container = (String)params.get("container");
	   String reqParam  = (String)params.get("reqParam");
	   String exitURL   = (String)params.get("exitURL");
	   String wantCtx   = (String)params.get("wantCtx");
        %>
        <a href='#' onclick="doCategorySelect('<%=ssp_process_oid%>', '<%=container%>',
        '<%=reqParam%>','<%=exitURL%>','<%=wantCtx%>')">
        <bean:write name="result" property="name"/></a>
      </td>
      <td headers="Version"><bean:write name="result" property="friendlyName"/></td>
    </tr>
  </logic:iterate>
  
  </table>  
  </div>
  </td>
  </tr>
</table>
</form>

</logic:equal>